<?php
namespace app\common\service;
use \app\common\model\UserCollectShop as UserCollectShopModel;

class UserCollectShop extends Base{
    public function __construct()
    {
        parent::__construct();
        $UserCollectShopModel =  new UserCollectShopModel();
        $this->model = $UserCollectShopModel;
    }
    public function collectStore($uid,$limit,$page){
        $map['user_id']=$uid;
        $list = $this->model->alias('cs')->field('s.*')
            ->where('cs.user_id',$uid)
            ->join('__LITESTORE_SHOP__ s','s.id=cs.shop_id')
            ->order('id desc')
            ->page($page)
            ->limit($limit);
        $datas = collection($list->with("getShopByTag")->select())->toArray();
//       $UserCollectShopModel = UserCollectShopModel::where($map)->page($page)->limit($limit);
//        $data = $UserCollectShopModel->with('myCollectStore')->with('getShopByTag')->select();
//        $datas = collection($data->with("getShopByTag")->select())->toArray();
//        $datas = collection($data)->toArray();
//        foreach($datas as &$v) {
//            foreach ($v["my_collect_store"] as &$vv) {
//                    $v['gid'] = $vv['id'];
//                    $v['name'] = $vv['name'];
//                    $v['address'] = $vv['address'];
//                    $v['desc'] = $vv['desc'];
//                    $v['info'] = $vv['info'];
//                    $v['longitude'] = $vv['longitude'];
//                    $v['latitude'] = $vv['latitude'];
//                    $v['average'] = $vv['average'];
//                    $v['shop_image'] = $vv['shop_image'];
//            }
//            foreach ($v["get_shop_by_tag"] as &$vvv) {
//                $v['tag_list'][] = [
//                    'id' => $vvv['id'],
//                    'tagname' => $vvv['tagname']
//                ];
//            }
//            unset($v['get_shop_by_tag']);
//            unset($v['my_collect_store']);
//        }
        return $datas;
    }


}